package tjs.study.notes.dotest.proxy.spring.lost;

import org.redisson.spring.starter.RedissonAutoConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@ComponentScan(excludeFilters = {
        @ComponentScan.Filter(type = FilterType.REGEX, pattern = "tjs.study.notes.dotest.mongo.*")
})
@SpringBootApplication(
        exclude = {RedisAutoConfiguration.class, RedissonAutoConfiguration.class, MongoAutoConfiguration.class})
@EnableTransactionManagement(proxyTargetClass = true)
public class FinalLostDoTest implements CommandLineRunner {
    /**
     * {@link  org.springframework.aop.framework.CglibAopProxy#getProxy(ClassLoader)}
     *      {@link  org.springframework.aop.framework.ObjenesisCglibAopProxy#createProxyClassAndInstance}
     *          {@link  org.springframework.objenesis.instantiator.sun.SunReflectionFactoryInstantiator#newInstance}
     *          [this.mungedConstructor.newInstance((Object[])null); // 强制使用无参构造函数实例化代理类]
     * 
     * {@link  org.springframework.aop.framework.CglibAopProxy.DynamicAdvisedInterceptor#intercept}
     *      [targetSource.getTarget();// 调用目标代理方法时，传入的是真实实例化后的bean]
     */
    public static void main(String[] args) {
        System.setProperty(org.springframework.cglib.core.DebuggingClassWriter.DEBUG_LOCATION_PROPERTY, "/Users/piangpiang/Documents/my-workspace/my-mayun/tjs-study-notes-test2/tjs-study-notes/tjs-study-notes/tjs-study-dotest/src/main/java/tjs/study/notes/dotest/proxy/spring/lost/proxyClass");
        SpringApplication.run(FinalLostDoTest.class, args);
    }
    
    @Autowired
    private Son son;

    @Override
    public void run(String... args) throws Exception {
        son.runFinal();
        son.runNotFinal();
    }
  
}
